
// Source File Name:   ActFactoryImpl.java

package com.sunwayhorizo.health.hl7.factories;

import com.sunwayhorizo.health.hl7.common.*;
import com.sunwayhorizo.health.hl7.datatypes.*;
import com.sunwayhorizo.health.hl7.persistent.*;
import com.sunwayhorizo.health.hl7.rim.*;
import com.sunwayhorizo.health.hl7.vocabulary.*;

public class ActFactoryImpl extends ActFactory {

    public static final String RCS_ID = "$Header: ActFactoryImpl.java 1.0 2008/12/08 09:16:42 amchanda noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: ActFactoryImpl.java 1.0 2008/12/08 09:16:42 amchanda noship $", "com.sunwayhorizo.health.facade.factories.comm");
//    private RimServiceBean session;
    private FactoryValidation validation;
//    private DataTypeFactory dataTypeFactory;
    
    public ActFactoryImpl()    {    
        }

//    public ActFactoryImpl(ServiceLocator servicelocator)
//        throws Hl7Exception
//    {
////        session = (RimServiceBean)servicelocator.getRimService();
//        dataTypeFactory = DataTypeFactory.getInstance(servicelocator);
//        validation = new FactoryValidation(session);
//    }

    public Act newAct(CS cs, CS cs1, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        Object obj = null;
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("actClass");
        if(cs1 == null || cs1.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        if(cs.equal(ActClass.TRNS).isTrue())
            obj = newTransportation(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.CTTEVENT).isTrue())
            obj = newClinicalTrialTimepointEvent(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.DOCBODY).isTrue())
            obj = newDocumentBody(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.INVE).isTrue())
            obj = newInvoiceElement(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.PROC).isTrue())
            obj = newProcedure(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.INFO).isTrue())
            obj = newInformation(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ACSN).isTrue())
            obj = newAccession(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.BATTERY).isTrue())
            obj = newBattery(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.CONTREG).isTrue())
            obj = newContainerRegistration(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ROIOVL).isTrue())
            obj = newOverlayROI(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.SBADM).isTrue())
            obj = newSubstanceAdministration(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.DGIMG).isTrue())
            obj = newDiagnosticImage(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.DOCCLIN).isTrue())
            obj = newClinicalDocument(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.INVSTG).isTrue())
            obj = newInvestigation(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ACCT).isTrue())
            obj = newAccount(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.LIST).isTrue())
            obj = newWorkingList(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.INC).isTrue())
            obj = newIncident(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.INFRM).isTrue())
            obj = newInform(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.DOC).isTrue())
            obj = newDocument(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.FCNTRCT).isTrue())
            obj = newFinancialContract(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.CNTRCT).isTrue())
            obj = newContract(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.SPLY).isTrue())
            obj = newSupply(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.CATEGORY).isTrue())
            obj = newCategory(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.COV).isTrue())
            obj = newCoverage(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.DIET).isTrue())
            obj = newDiet(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.STC).isTrue())
            obj = newStateTransitionControl(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.FOLDER).isTrue())
            obj = newFolder(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.CLNTRL).isTrue())
            obj = newClinicalTrial(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.SPCOBS).isTrue())
            obj = newSpecimenObservation(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.OBSCOR).isTrue())
            obj = newCorrelatedObservationSequences(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.EHR).isTrue())
            obj = newElectronicHealthRecord(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.CDALVLONE).isTrue())
            obj = newCDAL1Document(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.COND).isTrue())
            obj = newCondition(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.OUTB).isTrue())
            obj = newOutbreak(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.CNOD).isTrue())
            obj = newConditionNode(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ENC).isTrue())
            obj = newPatientEncounter(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.EXTRACT).isTrue())
            obj = newExtract(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.TOPIC).isTrue())
            obj = newTopic(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ACTN).isTrue())
            obj = newAction(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.PCPR).isTrue())
            obj = newPatientCareProvision(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.REG).isTrue())
            obj = newRegistryAct(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.COMPOSITION).isTrue())
            obj = newComposition(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.OBS).isTrue())
            obj = newObservation(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ENTRY).isTrue())
            obj = newEntry(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ADJUD).isTrue())
            obj = newAdjudication(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.SPCTRT).isTrue())
            obj = newSpecimenTreatment(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.CLUSTER).isTrue())
            obj = newCluster(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ORGANIZER).isTrue())
            obj = newOrganizer(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ALRT).isTrue())
            obj = newDetectedIssue(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ACCM).isTrue())
            obj = newAccommodation(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.CASE).isTrue())
            obj = newPublicHealthCase(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.ROIBND).isTrue())
            obj = newBoundedROI(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.OBSSER).isTrue())
            obj = newObservationSeries(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.CONS).isTrue())
            obj = newConsent(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.MPROT).isTrue())
            obj = newMonitoringProgram(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.DOCSECT).isTrue())
            obj = newDocumentSection(cs1, cd, set_ii);
        else
        if(cs.equal(ActClass.XACT).isTrue())
        {
            obj = newFinancialTransaction(cs1, cd, set_ii);
        } else
        {
            obj = new Act();
            
/*            if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
            {
                ((Act)obj).setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
            } else
            {
                validation.validateOID(set_ii);
                ((Act)obj).setAttribute("Id", set_ii.union(session.getNextII()));
            }
*/
            ((Act)obj).setMoodCode(cs1);
            ((Act)obj).setCode(cd);
        }
        return ((Act) (obj));
    }

    public ControlAct newControlActEvent(CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        ControlAct controlact = new ControlAct();
        controlact.setCode(cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            controlact.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            controlact.setId( set_ii.union(session.getNextII()));
        }
*/
        controlact.setClassCode(ActClass.CACT);
       // controlact.setId(set_ii);
        controlact.setMoodCode(ActMood.EVN);
        
        return controlact;
    }

    public Act newRegistryAct(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();        
        act.setMoodCode(cs);
        act.setCode(cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.REG);
       // act.setId(set_ii);
        return act;
    }

    public PatientEncounter newPatientEncounter(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        PatientEncounter patientencounter = new PatientEncounter();
        patientencounter.setMoodCode( cs);
        patientencounter.setCode(cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            patientencounter.setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            patientencounter.setAttribute("Id", set_ii.union(session.getNextII()));
        }
*/
        patientencounter.setClassCode(ActClass.ENC);
        //patientencounter.setId(set_ii);
        return patientencounter;
    }

    public Observation newObservation(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observationimpl.setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observationimpl.setAttribute("Id", set_ii.union(session.getNextII()));
        }
*/
        observation.setClassCode(ActClass.OBS);
      //  observation.setId(set_ii);
        
        return observation;
    }

    public Act newComposition(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setAttribute("Id", set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.COMPOSITION);
        return act;
    }

    public Document newDocument(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Document document = new Document();
        document.setMoodCode( cs);
        document.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            document.setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            document.setAttribute("Id", set_ii.union(session.getNextII()));
        }
*/
        document.setClassCode(ActClass.DOC);
        //document.setId(set_ii);
        return document;
    }

    public SubstanceAdministration newSubstanceAdministration(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        SubstanceAdministration substanceadministration = new SubstanceAdministration();
        substanceadministration.setMoodCode(cs);
        substanceadministration.setCode(cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            substanceadministration.setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            substanceadministration.setAttribute("Id", set_ii.union(session.getNextII()));
        }
*/        
        substanceadministration.setClassCode(ActClass.SBADM);
        return substanceadministration;
    }

    public Document newClinicalDocument(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Document document = new Document();
        document.setMoodCode( cs);
        document.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            document.setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            document.setAttribute("Id", set_ii.union(session.getNextII()));
        }
*/
        document.setClassCode( ActClass.DOCCLIN);
       //document.setId(set_ii);
        return document;
    }

    public Document newCDAL1Document(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Document document = new Document();
        document.setMoodCode( cs);
        document.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            document.setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            document.setAttribute("Id", set_ii.union(session.getNextII()));
        }
*/
        document.setClassCode( ActClass.CDALVLONE);
        //document.setId(set_ii);
        return document;
    }

    public Act newEntry(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.ENTRY);
       // act.setId(set_ii);
        return act;
    }

    public Observation newBattery(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setAttribute("Id", set_ii.union(session.getNextII()));
        }
*/
        observation.setClassCode( ActClass.BATTERY);
       // observation.setId(set_ii);
        return observation;
    }

    public Act newCluster(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.CLUSTER);
        //act.setId(set_ii);
        return act;
    }

    public Act newExtract(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.EXTRACT);
        //act.setId(set_ii);
        return act;
    }

    public Act newElectronicHealthRecord(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.EHR);
       // act.setId(set_ii);
        return act;
    }

    public Act newFolder(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.FOLDER);
        return act;
    }

    public Act newOrganizer(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.ORGANIZER);
       // act.setId(set_ii);
        return act;
    }

    public Act newCategory(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.CATEGORY);
       // act.setId(set_ii);
        return act;
    }

    public Act newDocumentBody(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.DOCBODY);
        return act;
    }

    public Act newDocumentSection(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.DOCSECT);
        //act.setId(set_ii);
        return act;
    }

    public Act newTopic(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.TOPIC);
        return act;
    }

    public Act newAccommodation(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
                {
                    act.setId( dataTypeFactory.newSET_II(session.getNextII()));
                } else
                {
                    validation.validateOID(set_ii);
                    act.setId( set_ii.union(session.getNextII()));
                }
        */
        act.setClassCode( ActClass.ACCM);
       // act.setId(set_ii);
        return act;
    }

    public Account newAccount(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Account account = new Account();
        account.setMoodCode( cs);
        account.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            account.setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            account.setAttribute("Id", set_ii.union(session.getNextII()));
        }
*/
        account.setClassCode(ActClass.ACCT);
       // account.setId(set_ii);
        return account;
    }

    public Act newAccession(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
                {
                    act.setId( dataTypeFactory.newSET_II(session.getNextII()));
                } else
                {
                    validation.validateOID(set_ii);
                    act.setId( set_ii.union(session.getNextII()));
                }
        */
        act.setClassCode( ActClass.ACSN);
       // act.setId(set_ii);
        return act;
    }

    public Act newAdjudication(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
*/
        act.setClassCode( ActClass.ADJUD);
       // act.setId(set_ii);
        return act;
    }

    public ControlAct newAction(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        ControlAct controlact = new ControlAct();
        controlact.setMoodCode( cs);
        controlact.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            controlact.setAttribute("Id", dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            controlact.setAttribute("Id", set_ii.union(session.getNextII()));
        }
*/
        controlact.setClassCode(ActClass.ACTN);
        return controlact;
    }

    public ControlAct newInformation(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        ControlAct controlact = new ControlAct();
        controlact.setMoodCode( cs);
        controlact.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            controlact.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            controlact.setId( set_ii.union(session.getNextII()));
        }
*/
        controlact.setClassCode(ActClass.INFO);
        return controlact;
    }

    public ControlAct newStateTransitionControl(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        ControlAct controlact = new ControlAct();
        controlact.setMoodCode( cs);
        controlact.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            controlact.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            controlact.setId( set_ii.union(session.getNextII()));
        }
        */
        controlact.setClassCode(ActClass.STC);
        return controlact;
    }

    public Act newContract(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
        */
        act.setClassCode( ActClass.CNTRCT);
        return act;
    }

    public FinancialContract newFinancialContract(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        FinancialContract financialcontract = new FinancialContract();
        financialcontract.setMoodCode( cs);
        financialcontract.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            financialcontract.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            financialcontract.setId( set_ii.union(session.getNextII()));
        }
*/
        financialcontract.setClassCode(ActClass.FCNTRCT);
        return financialcontract;
    }

    public FinancialContract newCoverage(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        FinancialContract financialcontract = new FinancialContract();
        financialcontract.setMoodCode( cs);
        financialcontract.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            financialcontract.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            financialcontract.setId( set_ii.union(session.getNextII()));
        }
        */
        financialcontract.setClassCode(ActClass.COV);
        return financialcontract;
    }

    public Act newConsent(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
        */
        act.setClassCode( ActClass.CONS);
        return act;
    }

    public DeviceTask newContainerRegistration(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        DeviceTask devicetask = new DeviceTask();
        devicetask.setMoodCode( cs);
        devicetask.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            devicetask.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            devicetask.setId( set_ii.union(session.getNextII()));
        }
*/
        devicetask.setClassCode(ActClass.CONTREG);
        return devicetask;
    }

    public Act newClinicalTrialTimepointEvent(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
        */
        act.setClassCode( ActClass.CTTEVENT);
        return act;
    }

    public Act newIncident(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
        */
        act.setClassCode( ActClass.INC);
        return act;
    }

    public Act newInform(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
        */
        act.setClassCode( ActClass.INFRM);
        return act;
    }

    public InvoiceElement newInvoiceElement(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        InvoiceElement invoiceelement = new InvoiceElement();
        invoiceelement.setMoodCode( cs);
        invoiceelement.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            invoiceelement.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            invoiceelement.setId( set_ii.union(session.getNextII()));
        }
*/
        invoiceelement.setClassCode(ActClass.INVE);
        return invoiceelement;
    }

   
    public WorkingList newWorkingList(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        WorkingList workinglist = new WorkingList();
        workinglist.setMoodCode( cs);
        workinglist.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            workinglist.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            workinglist.setId( set_ii.union(session.getNextII()));
        }
*/
        workinglist.setClassCode(ActClass.LIST);
        return workinglist;
    }

    public Observation newBoundedROI(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
*/
        observation.setClassCode(ActClass.ROIBND);
        return observation;
    }

    public Observation newOverlayROI(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
        */
        observation.setClassCode(ActClass.ROIOVL);
        return observation;
    }

    public Observation newDetectedIssue(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
        */
        observation.setClassCode(ActClass.ALRT);
        return observation;
    }

    public PublicHealthCase newPublicHealthCase(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        PublicHealthCase publichealthcase = new PublicHealthCase();
        publichealthcase.setMoodCode( cs);
        publichealthcase.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            publichealthcase.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            publichealthcase.setId( set_ii.union(session.getNextII()));
        }
*/
        publichealthcase.setClassCode(ActClass.CASE);
        return publichealthcase;
    }

    public PublicHealthCase newOutbreak(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        PublicHealthCase publichealthcase = new PublicHealthCase();
        publichealthcase.setMoodCode( cs);
        publichealthcase.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            publichealthcase.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            publichealthcase.setId( set_ii.union(session.getNextII()));
        }
        */
        publichealthcase.setClassCode(ActClass.OUTB);
        return publichealthcase;
    }

    public Observation newClinicalTrial(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
        */
        observation.setClassCode(ActClass.CLNTRL);
        return observation;
    }

    public Observation newConditionNode(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
        */
        observation.setClassCode(ActClass.CNOD);
        return observation;
    }

    public Observation newCondition(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
        */
        observation.setClassCode(ActClass.COND);
        return observation;
    }

    public DiagnosticImage newDiagnosticImage(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        DiagnosticImage diagnosticimage = new DiagnosticImage();
        diagnosticimage.setMoodCode( cs);
        diagnosticimage.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            diagnosticimage.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            diagnosticimage.setId( set_ii.union(session.getNextII()));
        }
*/
        diagnosticimage.setClassCode(ActClass.DGIMG);
        return diagnosticimage;
    }

    public Observation newInvestigation(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
        */
        observation.setClassCode(ActClass.INVSTG);
        return observation;
    }

    public Observation newMonitoringProgram(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
        */
        observation.setClassCode(ActClass.MPROT);
        return observation;
    }

    public Observation newObservationSeries(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
        */
        observation.setClassCode(ActClass.OBSSER);
        return observation;
    }

    public Observation newCorrelatedObservationSequences(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
        */
        observation.setClassCode(ActClass.OBSCOR);
        return observation;
    }

    public Observation newSpecimenObservation(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Observation observation = new Observation();
        observation.setMoodCode( cs);
        observation.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            observation.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            observation.setId( set_ii.union(session.getNextII()));
        }
        */
        observation.setClassCode(ActClass.SPCOBS);
        return observation;
    }

    public Act newPatientCareProvision(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
        */
        act.setClassCode( ActClass.PCPR);
        return act;
    }

    public Procedure newProcedure(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Procedure procedure = new Procedure();
        procedure.setMoodCode( cs);
        procedure.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            procedure.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            procedure.setId( set_ii.union(session.getNextII()));
        }
*/
        procedure.setClassCode(ActClass.PROC);
        return procedure;
    }

    public Act newSpecimenTreatment(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
        */
        act.setClassCode( ActClass.SPCTRT);
        return act;
    }

    public Supply newSupply(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Supply supply = new Supply();
        supply.setMoodCode( cs);
        supply.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            supply.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            supply.setId( set_ii.union(session.getNextII()));
        }
*/
        supply.setClassCode(ActClass.SPLY);
        return supply;
    }

    public Diet newDiet(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Diet diet = new Diet();
        diet.setMoodCode( cs);
        diet.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            diet.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            diet.setId( set_ii.union(session.getNextII()));
        }
*/
        diet.setClassCode(ActClass.DIET);
        return diet;
    }

    public Act newTransportation(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        Act act = new Act();
        act.setMoodCode( cs);
        act.setCode( cd);
        /*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            act.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            act.setId( set_ii.union(session.getNextII()));
        }
        */
        act.setClassCode( ActClass.TRNS);
        return act;
    }

    public FinancialTransaction newFinancialTransaction(CS cs, CD cd, SET_II set_ii)
        throws Hl7Exception
    {
        if(cs == null || cs.isNull().isTrue())
            throw validation.newParameterMissingException("moodCode");
        FinancialTransaction financialtransaction = new FinancialTransaction();
        financialtransaction.setMoodCode( cs);
        financialtransaction.setCode( cd);
/*        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
        {
            financialtransaction.setId( dataTypeFactory.newSET_II(session.getNextII()));
        } else
        {
            validation.validateOID(set_ii);
            financialtransaction.setId( set_ii.union(session.getNextII()));
        }
*/
        financialtransaction.setClassCode(ActClass.XACT);
        return financialtransaction;
    }

    public Act makeReference(ReferenceModifier referencemodifier, CS cs, CS cs1, CD cd, SET_II set_ii, int i)
        throws Hl7Exception
    {
        Object obj = null;
        if(referencemodifier == null)
            throw validation.newParameterMissingException("modifier");
        if(set_ii == null || set_ii.isNull().isTrue() || set_ii.isEmpty().isTrue())
            throw validation.newParameterMissingException("id");
        if(referencemodifier.compareTo(ReferenceModifier.CREATE_IF) == 0)
        {
            if(cs == null || cs.isNull().isTrue())
                throw validation.newParameterMissingException("actClass");
            if(cs1 == null || cs1.isNull().isTrue())
                throw validation.newParameterMissingException("moodCode");
        }
        if(cs != null && cs.equal(ActClass.ACSN).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode( ActClass.ACSN);
        } else
        if(cs != null && cs.equal(ActClass.CONS).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode( ActClass.CONS);
        } else
        if(cs != null && cs.equal(ActClass.DIET).isTrue())
        {
            obj = new Diet(referencemodifier);
            ((Act) (obj)).setClassCode( ActClass.DIET);
        } else
        if(cs != null && cs.equal(ActClass.SPLY).isTrue())
        {
            obj = new Supply(referencemodifier);
            ((Act) (obj)).setClassCode( ActClass.SPLY);
        } else
        if(cs != null && cs.equal(ActClass.SPCTRT).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.SPCTRT);
        } else
        if(cs != null && cs.equal(ActClass.CLUSTER).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.CLUSTER);
        } else
        if(cs != null && cs.equal(ActClass.ADJUD).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.ADJUD);
        } else
        if(cs != null && cs.equal(ActClass.PCPR).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.PCPR);
        } else
        if(cs != null && cs.equal(ActClass.INVE).isTrue())
        {
            obj = new InvoiceElement(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.INVE);
        } else
        if(cs != null && cs.equal(ActClass.CASE).isTrue())
        {
            obj = new PublicHealthCase(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.CASE);
        } else
        if(cs != null && cs.equal(ActClass.ACCT).isTrue())
        {
            obj = new Account(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.ACCT);
        } else
        if(cs != null && cs.equal(ActClass.CATEGORY).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.CATEGORY);
        } else
        if(cs != null && cs.equal(ActClass.COND).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.COND);
        } else
        if(cs != null && cs.equal(ActClass.DGIMG).isTrue())
        {
            obj = new DiagnosticImage(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.DGIMG);
        } else
        if(cs != null && cs.equal(ActClass.COMPOSITION).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.COMPOSITION);
        } else
        if(cs != null && cs.equal(ActClass.CACT).isTrue())
        {
            obj = new ControlAct(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.CACT);
        } else
        if(cs != null && cs.equal(ActClass.ALRT).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.ALRT);
        } else
        if(cs != null && cs.equal(ActClass.REG).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.REG);
        } else
        if(cs != null && cs.equal(ActClass.ACCM).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.ACCM);
        } else
        if(cs != null && cs.equal(ActClass.INFO).isTrue())
        {
            obj = new ControlAct(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.INFO);
        } else
        if(cs != null && cs.equal(ActClass.STC).isTrue())
        {
            obj = new ControlAct(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.STC);
        } else
        if(cs != null && cs.equal(ActClass.CONTREG).isTrue())
        {
            obj = new DeviceTask(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.CONTREG);
        } else
        if(cs != null && cs.equal(ActClass.INFRM).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.INFRM);
        } else
        if(cs != null && cs.equal(ActClass.OBSCOR).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.OBSCOR);
        } else
        if(cs != null && cs.equal(ActClass.INC).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.INC);
        } else
        if(cs != null && cs.equal(ActClass.FOLDER).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.FOLDER);
        } else
        if(cs != null && cs.equal(ActClass.DOCBODY).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.DOCBODY);
        } else
        if(cs != null && cs.equal(ActClass.OBS).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.OBS);
        } else
        if(cs != null && cs.equal(ActClass.CNTRCT).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.CNTRCT);
        } else
        if(cs != null && cs.equal(ActClass.OUTB).isTrue())
        {
            obj = new PublicHealthCase(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.OUTB);
        } else
        if(cs != null && cs.equal(ActClass.CLNTRL).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.CLNTRL);
        } else
        if(cs != null && cs.equal(ActClass.BATTERY).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.BATTERY);
        } else
        if(cs != null && cs.equal(ActClass.COV).isTrue())
        {
            obj = new FinancialContract(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.COV);
        } else
        if(cs != null && cs.equal(ActClass.CDALVLONE).isTrue())
        {
            obj = new Document(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.CDALVLONE);
        } else
        if(cs != null && cs.equal(ActClass.MPROT).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.MPROT);
        } else
        if(cs != null && cs.equal(ActClass.ORGANIZER).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.ORGANIZER);
        } else
        if(cs != null && cs.equal(ActClass.FCNTRCT).isTrue())
        {
            obj = new FinancialContract(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.FCNTRCT);
        } else
        if(cs != null && cs.equal(ActClass.DOC).isTrue())
        {
            obj = new Document(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.DOC);
        } else
        if(cs != null && cs.equal(ActClass.EHR).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.EHR);
        } else
        if(cs != null && cs.equal(ActClass.TOPIC).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.TOPIC);
        } else
        if(cs != null && cs.equal(ActClass.TRNS).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.TRNS);
        } else
        if(cs != null && cs.equal(ActClass.ROIOVL).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.ROIOVL);
        } else
        if(cs != null && cs.equal(ActClass.DOCCLIN).isTrue())
        {
            obj = new Document(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.DOCCLIN);
        } else
        if(cs != null && cs.equal(ActClass.ACTN).isTrue())
        {
            obj = new ControlAct(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.ACTN);
        } else
        if(cs != null && cs.equal(ActClass.ENTRY).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.ENTRY);
        } else
        if(cs != null && cs.equal(ActClass.LIST).isTrue())
        {
            obj = new WorkingList(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.LIST);
        } else
        if(cs != null && cs.equal(ActClass.OBSSER).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.OBSSER);
        } else
        if(cs != null && cs.equal(ActClass.XACT).isTrue())
        {
            obj = new FinancialTransaction(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.XACT);
        } else
        if(cs != null && cs.equal(ActClass.SBADM).isTrue())
        {
            obj = new SubstanceAdministration(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.SBADM);
        } else
        if(cs != null && cs.equal(ActClass.ENC).isTrue())
        {
            obj = new PatientEncounter(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.ENC);
        } else
        if(cs != null && cs.equal(ActClass.PROC).isTrue())
        {
            obj = new Procedure(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.PROC);
        } else
        if(cs != null && cs.equal(ActClass.ROIBND).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.ROIBND);
        } else
        if(cs != null && cs.equal(ActClass.INVSTG).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.INVSTG);
        } else
        if(cs != null && cs.equal(ActClass.SPCOBS).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.SPCOBS);
        } else
        if(cs != null && cs.equal(ActClass.CTTEVENT).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.CTTEVENT);
        } else
        if(cs != null && cs.equal(ActClass.DOCSECT).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.DOCSECT);
        } else
        if(cs != null && cs.equal(ActClass.CNOD).isTrue())
        {
            obj = new Observation(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.CNOD);
        } else
        if(cs != null && cs.equal(ActClass.EXTRACT).isTrue())
        {
            obj = new Act(referencemodifier);
            ((Act) (obj)).setClassCode(  ActClass.EXTRACT);
        } else
        {
            obj = new Act(referencemodifier);
            ((InfrastructureRoot) (obj)).setClassCode(  cs);
        }
        ((Act) (obj)).setCode( cd);
        ((Act) (obj)).setMoodCode( cs1);
        
        return ((Act) (obj));
    }

	@Override
	public ActParticipation newActParticipation() throws Hl7Exception {
	
		return new ActParticipation();
	}

	@Override
	public ActRelationship newActRelationship() throws Hl7Exception {
		
		return new ActRelationship();
	}


/*    public QueryAct newQueryAct(CoreFetch corefetch)
        throws CTBException
    {
        QueryAct queryact = new QueryAct();
        queryact.setMoodCode( ActMood.EVN);
        queryact.setTopLevelFetch(corefetch);
        
        return queryact;
    }
*/
}
